package com.wl.week_01.Producer_Consumer;

/**
 * 消费者模型
 * @author TaiZai
 * @data 2024/9/30 16:20
 */
public class ConsumerThread implements Runnable{
    @Override
    public void run() {
        while (true) {
            if (Product_House.getProducts().size() > 0) {
                Product_House.get();
                System.out.println("消费者消费了一个产品，剩余: " + Product_House.getProducts().size() + " 个");
            } else {
                System.out.println("仓库为空，无法再消费");
            }
            try {
                Thread.sleep(4000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
